{include file="public/header" /}
<blockquote class="layui-elem-quote">
    一键菜单
</blockquote>
<form class="layui-form layui-form-pane kllxs-form" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">菜单等级</label>
        <div class="layui-input-block">
            <select name="menu_pid" id="">
                <option value="0">顶级菜单</option>
                {foreach $Menu_data as $k=>$v}
                <option value="{$v.id}">{$v.name}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">菜单名称</label>
        <div class="layui-input-block">
            <input type="text" name="table_name" placeholder="菜单名称" class="layui-input" value="{$find.TABLE_COMMENT}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">菜单图标</label>
        <div class="layui-input-inline">
            <div id="iconSelect"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">强制覆盖</label>
        <div class="layui-input-block">
            <input type="radio" name="is_cover" value="false" title="否" checked>
            <input type="radio" name="is_cover" value="true" title="是">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-inlink">
            <button class="layui-btn" lay-submit lay-filter="kllxs-submit">确认</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
{include file="public/footer" /}
<script>

    layui.use(["form", "popup", "xmSelect", "jquery"], function () {
        var form = layui.form;
        var popup = layui.popup;
        var xmSelect = layui.xmSelect;
        var $ = layui.$;

        //图标
        var xm = xmSelect.render({
            el: '#iconSelect',
            tips: '请选择菜单图标',
            paging: true,
            radio: true,
            name: "icon_str",
            filterable: true,
            data: [],
            model: {
                label: {
                    block: {
                        template: function (item, sels) {
                            return `<i class="${item.value}"></i>&emsp;${item.name}`
                        },
                    },
                }
            },
            template({ item, sels, name, value }) {
                return `<i class="${value}"></i>&emsp;${item.name}`
            },
        })
        // 动态数据
        $.get('/admin/icon.json', function (res) {
            xm.update({
                data: res
            })
        })

        form.on('submit(kllxs-submit)', function (data) {
            var field = data.field; // 获取表单全部字段值

            popup.formSubmit("", field)

            return false; // 阻止默认 form 跳转
        })
    })
</script>